﻿using System;
using Dng.Application.Logging;

namespace ShippingManage
{
	public interface IForm
	{
		void Save();
		void New();
		void Open();
		void Print();
	}

	public class FormBase : System.Windows.Forms.Form, IForm
	{
		public void Save()
		{
			try
			{
				OnSave();
			}
			catch (Exception ex)
			{
				Log.Error(ex, "Save data failed.");
			}
		}
		protected virtual void OnSave() { }

		public void New()
		{
			try
			{
				OnNew();
			}
			catch (Exception ex)
			{
				Log.Error(ex, "New data failed.");
			}
		}
		protected virtual void OnNew() { }

		public void Open()
		{
			try
			{
				OnOpen();
			}
			catch (Exception ex)
			{
				Log.Error(ex, "Open data failed.");
			}
		}
		protected virtual void OnOpen() { }

		public void Print()
		{
			try
			{
				OnPrint();
			}
			catch (Exception ex)
			{
				Log.Error(ex, "Print data failed.");
			}
		}
		protected virtual void OnPrint() { }
	}
}
